<?php
$app = Blyn::app()->getActiveApp();
$screen = Blyn::app()->getUIManager()->getCurrentScreen();
?>

<link rel="stylesheet" type="text/css"
      href="<?php echo Yii::app()->request->baseUrl; ?>/css/bootstrap-datetimepicker.min.css" />
<script  type="text/javascript"
         src="<?php echo Yii::app()->request->baseUrl; ?>/js/bootstrap-datetimepicker.min.js"/>

<script type="text/javascript">
    $(document).ready(function() {
        $("#selectAll").click(function() {
            if ($(this).attr("checked") == "checked") {
                $(":checkbox").attr("checked", true);
            } else {
                $(":checkbox").attr("checked", false);
            }
        });

    });
</script> 

<script type="text/javascript">
    $(function() {
        $('.tree li:has(ul)').addClass('parent_li').find(' > span').attr('title', 'Collapse this branch');
        $('.tree li.parent_li > span').on('click', function(e) {
            var children = $(this).parent('li.parent_li').find(' > ul > li');
            if (children.is(":visible")) {
                children.hide('fast');
                $(this).attr('title', 'Expand this branch').find(' > i').addClass('icon-plus-sign').removeClass('icon-minus-sign');
            } else {
                children.show('fast');
                $(this).attr('title', 'Collapse this branch').find(' > i').addClass('icon-minus-sign').removeClass('icon-plus-sign');
            }
            e.stopPropagation();
        });
    });</script>
<script type="text/javascript">
    $(function() {
        $("#Event_Shop_CX").click(function() {
            document.getElementById("Event_Shop_CX_View").style.display = '';
            document.getElementById("Event_Clothes_CX_View").style.display = 'none';
        });
        $("#Event_Clothes_CX").click(function() {
            document.getElementById("Event_Shop_CX_View").style.display = 'none';
            document.getElementById("Event_Clothes_CX_View").style.display = '';
        });
    });</script>

<?php
/*
  $control2 = new BUIControl('timeSlotListView');
  $viewData = array();
  //$viewData['timeSlotConfigView'] = $timeSlotConfigView;
  //$viewData['form'] = $form;
  //$viewData['model'] = $model;
  $viewData['eventId'] = $eventId;
  $viewData['configId'] = $configId;
  $control2->addRenderView('timeSlotConfigList', 'orderConfig_add_timeSlot_list_view', $viewData);
  $control2->render();
 * 
 */
?>
<?php
$timeSlotConfigView = array();
$configTable = new BPSheet('orderConfig');
if (isset($configId) && $configId > 0) {
    $config = $configTable->getListById($configId);
    $timeSlotConfigTable = new BPSheet('orderTimeslotConfig', $config);
    $timeSlotConfigView = $timeSlotConfigTable->getView();
}
?>
<fieldset>
    <table class="table table-hover">
        <thead>
            <tr>
                <th>
                    <input type="checkbox"  id="selectAll"> 
                </th>
                <th><?php echo '序号'; ?></th>
                <th><?php echo '名称'; ?></th>
                <th><?php echo '开始时间'; ?></th>
                <th><?php echo '结束时间'; ?></th>
                <th><?php echo '时间段长度'; ?></th>
                <th><?php echo '操作'; ?></th>
            </tr> 
        </thead>
        <tbody>
            <?php
            $serial = 0;
            foreach ($timeSlotConfigView as $config) {
                $configId = $config->getId();
                $serial++;
                $categoryId = '-';
                $timeSlotConfigName = '-';
                $timeSlotActiveTime = '-';
                $timeSlotExpireTime = '-';
                $timeSlotLength = '-';
                if ($config->getItem('timeSlotConfigName') instanceof BTreeItem) {
                    $timeSlotConfigName = $config->getItem('timeSlotConfigName')->getValue();
                    $timeSlotActiveTime = $config->getItem('timeSlotActiveTime')->getValue();
                    $timeSlotExpireTime = $config->getItem('timeSlotExpireTime')->getValue();
                    $timeSlotLength = $config->getItem('timeSlotLength')->getValue();
                }
                ?>
                <tr>
                    <td><label class="checkbox">
                            <input type="checkbox" name="checkbox[]" value="<?php echo $configId; ?>"> 
                        </label></td>
                    <td> <?php echo $serial; ?> </td>
                    <td> <?php echo $timeSlotConfigName; ?> </td>   
                    <td> <?php echo $timeSlotActiveTime; ?> </td>  
                    <td> <?php echo $timeSlotExpireTime; ?> </td>   
                    <td> <?php echo $timeSlotLength; ?> </td>    
                    <td>
                        <div class="row-fluid">                         
                            <?php
                            echo $control->getAjaxLink(array('name' => '修改', 'id' => 'showAddTimeslotConfig'), array(
                                'configId' => $configId,
                                    //'ajaxContainerId' => 'myModal',
                                    //'htmlOptions' => array(
                                    //'enctype' => 'multipart/form-data'),
                                    //'ajaxOptions' => array(
                                    //'complete' => 'function(){$("#ajax-loaderdiv").hide();$("#myModal").modal("show");}')
                            ));
                            echo " | ";
                            ?>                               
                            <?php
                            // echo $control->getAjaxLink(array('name' => '管理', 'id' => 'manageTimeslot'), array(
                            //'timeSlotId' => $timeSlotId,
                            // ));
                            ?> 
                            <?php
                            echo $control->getAjaxLink(array('name' => '删除', 'id' => 'deleteTimeslotConfig'), array(
                                'configId' => $configId,
                            ));
                            ?> 
                        </div>                      
                    </td>
                </tr>
            <?php } ?>
        </tbody>
    </table>

    <div class="row-fluid">
        <?php
        echo $control->getAjaxLink(array('name' => '新增时间段设置', 'id' => 'showAddTimeslotConfig'), array(
            'timeSlotConfigId' => 0,
            'eventId' => $eventId,
            'configId' => $configId,
            //'pageContainerId' => $pageControl->getAjaxContainerId(),
            'htmlOptions' => array(
                //'enctype' => 'multipart/form-data',
                'class' => 'btn'),
                //'ajaxOptions' => array(
                //'complete' => 'function(){$("#ajax-loaderdiv").hide();$("#myModal").modal("show");}')
        ));
        ?>
        <?php
        echo $control->getAjaxLink(array('name' => '删除设置', 'id' => 'deleteTimeslotConfig'), array(
            'htmlOptions' => array(
                'class' => 'btn',
            //'enctype' => 'multipart/form-data'
        )));
        ?>
    </div>   
    <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    </div>

    <div><input type="hidden" name="curPageNo" value="1"></div>

    <div class="pagination">  
        <ul>  
            <li class="active">
                <a href="javascript:void()">前一页</a>    </li>  
            <li class="active">
                <a href="javascript:void()">1</a>    </li>  
            <li class="active">
                <a href="javascript:void()">后一页</a>    </li>  
        </ul>  
    </div>



